
class Person {
    public String name;
    public int age;


    public void eat() {
        System.out.println(name+"正在吃饭！");
    }
    public void show() {
        System.out.println("姓名："+name+" 年龄："+age);
    }
}

public class Test {

    public static void main(String[] args) {
        Person person1 = new Person();
        Person person2 = new Person();
        person2 = person1; //这个表示person1这个引用指向了person2这个引用所指向的对象。
    }

    public static void main2(String[] args) {
        Person person1 = null;//当一个引用被赋值为null的时候,代表这个引用不指向任何对象
//        person1.name = "lisi";
//        person1.age = 10;
    }

    public static void main1(String[] args) {
        Person person = new Person();
        person.name = "zhangsan";
        person.age = 10;
        person.show();

        System.out.println("=================");
        Person person1 = new Person();
        person1.name = "lisi";
        person1.age = 18;
        person1.eat();
        person1.show();
    }
}
